/***************************************************************************
 *   Copyright (C) 2007 by ludo   *
 *   ludo42fr@free.fr   *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/
#include "QVlcException.h"



/**
 * \brief initialize vlc exception structure
 *
 **/
QVlcException::QVlcException ( QObject *parent )
		:QObject ( parent )
{
	libvlc_exception_init ( &_vlcexcep );
}

/**
 * \brief get pointer on internal vlc_exception
 *
 * use with care ! pointer will be valid as long as this object will exist
 * @return a pointer on vlc_exception, always valid as long as this object will exist
 **/
libvlc_exception_t* QVlcException::internalPointer()
{
  return &_vlcexcep;
}

/**
 * \brief get last error message
 *
 * @return empty string if no error or explanation obout last error
 **/
QString QVlcException::lastError()
{
	if ( !hasError() )
		return "";
	char *err=libvlc_exception_get_message ( &_vlcexcep );
	if ( err==NULL )
		return "";
	return QString ( err );

}


/**
 * \brief error occur ?
 *
 * @return true if an error was set
 **/
bool QVlcException::hasError()
{
	return libvlc_exception_raised ( &_vlcexcep ) ==1;
}


/**
 * \brief generate an error
 * @param msg the message to associate with this error
 **/
void QVlcException::raise ( const QString &msg )
{
	libvlc_exception_raise ( &_vlcexcep,msg.toAscii().data() );
}

/**
 * \brief unset current error
 *
 * no effect if no error set
 **/
void QVlcException::clear()
{
	libvlc_exception_clear ( &_vlcexcep );
}

